package com.vishnu.core;

public class SingleTonClass implements Cloneable {
private static SingleTonClass stc=null;

// private Constructor, no one can create an object to this class from other class
private SingleTonClass(){
}
public static SingleTonClass getSingleTonClass(){
	if(stc==null){
		stc=new SingleTonClass();
	}
	return stc;
}

public Object clone(){
	return this;
}
	

public static void main(String[] args) {
	SingleTonClass stc1=SingleTonClass.getSingleTonClass();
	SingleTonClass stc2=SingleTonClass.getSingleTonClass();
	SingleTonClass stc3=SingleTonClass.getSingleTonClass();
	SingleTonClass stc4=SingleTonClass.getSingleTonClass();
	
	System.out.println("stc1"+stc1);
	System.out.println("stc2"+stc2);
	System.out.println("stc3"+stc3);
	System.out.println("stc4"+stc4);
	SingleTonClass stc8=new SingleTonClass();
	System.out.println("s8="+stc8);
	System.out.println("stc4"+stc4);
	SingleTonClass stc5=null;
	try {
		 stc5=(SingleTonClass)stc4.clone();
	} catch (Exception e) {
		e.printStackTrace();
	}
	
	System.out.println("stc5="+stc5);
	SingleTonClass stc6=null;
	try {
		 stc6=(SingleTonClass)stc5.clone();
	} catch (Exception e) {
		e.printStackTrace();
	}
	
	System.out.println("stc6="+stc6);
}	
	
	
}
